home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------------------------
- FILENAME
-
- LaserSCIntf.h
-
- DESCRIPTION
-
- This file contains constant and type declarations for the data structures which are needed
- to use the LaserSCIntf.c code module. That code module provides a set of high level routines
- for invoking LaserWriterSC device commands.
-
- COPYRIGHT
-
- Copyright Apple Computer, Inc. 1989-1992
- All rights reserved.
-
- ---------------------------------------------------------------------------------------------*/
-
- #ifndef __LASERSCINTF__
- #define __LASERSCINTF__
-
- /*********************************************************************************
- * CONSTANTS *
- *********************************************************************************/
-
- // LaserWriterSC Sense Key Codes (causes of a Check Condition status)
- enum
- {
- kNotReady = 0x2, // Printer not ready (e.g. door open)
- kMediumError = 0x3, // Paper jam has occurred
- kHardwareError = 0x4, // Non-recoverable hardware error
- kIllegalRequest = 0x5, // Illegal command parameter passed to printer
- kUnitAttention = 0x6, // Printer has been turned on or reset
- kAbortedCommand = 0xB // Checksum mismatch in downloaded code
- };
-
- // LaserWriterSC Controller Status Bits and some Sense Data Bits
- enum
- {
- // Controller Status
- kRamFailMask = 0x20, // Dynamic RAM test failure
- kEngineFailMask = 0x10, // Laser printer engine initialization failure
-
- // Sense Data
- kEndOfMedium = 0x40 // Bit set when out of paper, or in manual mode and no paper fed in
- };
-
- // LaserWriterSC Engine Status 0 Bits - defines problem when kNotReady Sense Key received
- enum
- {
- kToner = 0x40, // No toner cartridge installed or installed improperly
- kTray = 0x20, // No paper cartridge installed or installed improperly
- kPaperOut = 0x10, // Paper out, or if in manual feed mode no paper has been fed in
- kJam = 0x08, // Paper jam
- kDoorOpened = 0x04, // Upper door of printer is open
- kTestPrint = 0x02, // Test printing is underway
- kHeatFixUnit = 0x01 // LaserWriter's fixing unit is being heated
- };
-
- // LaserWriterSC Engine Status 1 Bits - defines problem when kHardwareError Sense Key received
- enum
- {
- kFixingMalfunction = 0x40, // Fixing assembly has malfunctioned
- kLaserMalfunction = 0x20, // Laser has malfunctioned
- kPolyMalfunction = 0x10, // Polygon motor has malfunctioned
- kSerialMalfunction = 0x01 // Serial communication malfunction has occurred
- };
-
- // SCSI status byte values useful for checking state of printer
- enum
- {
- kGoodCondition = 0, // Printer not experiencing exception condition
- kCheckCondition = 2, // Printer is experiencing exception condition
- kBusy = 8 // Device is busy
- };
-
- // Definitions for the printer firmware SCSI commands
- enum
- {
- kSCReserved = 0x0000,
- kSCPrinterReady = 0x0000,
- kSCResetPrinter = 0x0100,
- kSCDownLoadCode = 0x0200,
- kSCRequestSense = 0x0300,
- kSCFormatMargin = 0x0400,
- kSCFormatImage = 0x0402,
- kSCDrawBits = 0x0500,
- kSCClearBits = 0x0600,
- kSCPrint = 0x0A00,
- kSCInquiry = 0x1200,
- kSCModeSelect = 0x1500,
- kSCReserveUnit = 0x1600,
- kSCReleaseUnit = 0x1700,
- kSCModeSense = 0x1A00
- };
-
-
- /*********************************************************************************
- * TYPES *
- *********************************************************************************/
-
- // SCInquiryData - Format of a LaserWriter SC Inquiry Response
-
- typedef struct
- {
- // First five bytes of structure are common to all SCSI devices. Layout of remaining bytes
- // is specific to the LaserWriter SC
-
- unsigned char peripheralType; // Type of SCSI peripheral (2 = printer type)
- unsigned char deviceType; // Type of Apple printer
- unsigned char version; // Version not currently being used
- unsigned char reserved1; // Reserved
- unsigned char additionalLength; // Number of bytes which follow (39 for II SC)
-
- unsigned char appleUnique; // Apple unique byte specifying toner, RAM and Paper size
- unsigned char reserved2; // Reserved
- unsigned char reserved3; // Reserved
- char vendorID[8]; // Vendor identifier in ASCII = "APPLE "
- char productID[16]; // Product identifier in ASCII = "PERSONAL LASER "
- char revisionLevel[4]; // Revision level in ASCII (e.g. "1.00")
- short reserved4; // Reserved
- char cmndsImplemented[6]; // Commands supported by the device
- } SCInquiryData,
- *SCInquiryDataPtr;
-
-
- // SCSenseData - Format of LaserWriter SC Request Sense Data
-
- typedef struct
- {
- unsigned char errorType; // Error class portion (always 7)
- unsigned char reserved1; // Reserved
- unsigned char senseKey; // Special flags indicating things like out of paper
- unsigned char infoByte3; // Four fields indicating difference between the requested
- unsigned char infoByte2; // allocation size and the actual memory available on
- unsigned char infoByte1; // the printer.
- unsigned char infoByte0; //
- unsigned char additionalSense; // Apple unique sense data
- unsigned char engineStatus0; // Field for not ready sense key
- unsigned char engineStatus1; // Field for hardware error sense key
- unsigned char controlStatus; // Indicates if hardware errors during diagnostics
- unsigned char reserved2; // Reserved
- } SCSenseData,
- *SCSenseDataPtr;
-
-
- /*********************************************************************************
- * DEFINES *
- *********************************************************************************/
-
- #define SenseKey(senseData) ((senseData.senseKey) & 0x0F)
-
- #define EngineStatus0(pSenseData, bitField) (((pSenseData->engineStatus0 & bitField) == bitField) ? true : false)
- #define NoToner(pSenseData) (EngineStatus0(pSenseData, kToner))
- #define NoPaperTray(pSenseData) (EngineStatus0(pSenseData, kTray))
- #define NoPaper(pSenseData) (EngineStatus0(pSenseData, kPaperOut))
- #define PaperJam(pSenseData) (EngineStatus0(pSenseData, kJam))
- #define DoorOpen(pSenseData) (EngineStatus0(pSenseData, kDoorOpened))
- #define TestPrint(pSenseData) (EngineStatus0(pSenseData, kTestPrint))
- #define HeatingFixUnit(pSenseData) (EngineStatus0(pSenseData, kHeatFixUnit))
-
- #define EngineStatus1(pSenseData, bitField) (((pSenseData->engineStatus1 & bitField) == bitField) ? true : false)
- #define FixingMalfunction(pSenseData) (EngineStatus1(pSenseData, kFixingMalfunction))
- #define LaserMalfunction(pSenseData) (EngineStatus1(pSenseData, kLaserMalfunction))
- #define PolyMalfunction(pSenseData) (EngineStatus1(pSenseData, kPolyMalfunction))
- #define SerialMalfunction(pSenseData) (EngineStatus1(pSenseData, kSerialMalfunction))
-
-
- /*********************************************************************************
- * FORWARD DECLARATIONS *
- **********************************************************************************/
-
- OSErr LaserSC_OpenConnection();
-
- OSErr LaserSC_GetDeviceStatus(short *deviceStatus);
-
- OSErr LaserSC_ResetDevice();
-
- OSErr LaserSC_GetSenseData(SCSenseDataPtr senseData);
-
- OSErr LaserSC_SetPageMargins(short leftMargin, short topMargin);
-
- OSErr LaserSC_SetPageDimensions(short bytesPerScanLine, short numScanLines);
-
- OSErr LaserSC_ClearBits(Rect *rectToClear);
-
- OSErr LaserSC_DrawBits(Ptr imageData, Rect *rectToDrawIn, short numBytesPerLine, short qdTransferMode);
-
- OSErr LaserSC_PrintPage(Boolean continuousPrint, Boolean clearPage);
-
- OSErr LaserSC_QueryPrinter(SCInquiryDataPtr inquiryData, char querySize);
-
- OSErr LaserSC_SetBuffandFeedMode(Boolean manualFeed, Boolean bufferedMode);
-
- long LaserSC_GetTimeoutForSCSICmnd(short scsiCmnd);
-
-
- #endif __LASERSCINTF__